interface response<T> {
  code: number
  data: T
  msg: string
}
Page({
  onLoad() {
    this.getData()
  },
  data: {
    message: '',
    jokeList: [] as string[]
  },

  getData() {
    wx.showLoading({
      title: '数据加载中...'
    })
    wx.request({
      method: 'GET',
      url: 'https://api-vue-base.itheima.net/api/joke',
      success: (res) => {
        console.log('res', res);
        wx.hideLoading()
        this.setData({
          message: res.data as string
        })

      }
    })


  },
  getDataList() {
    wx.request<response<string[]>>({
      url: 'https://api-vue-base.itheima.net/api/joke/list',
      method: 'GET',
      data: {
        num: 5
      },
      success: (res) => {
        this.setData({
          jokeList: res.data.data
        })
      }
    })
  },
})